package com.nut.spp.api.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nut.spp.api.req.CouponWhiteQueryReq;
import com.nut.spp.common.Result;
import com.nut.spp.entity.CouponWhite;
import com.nut.spp.service.CouponWhiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/admin/couponWhite")
public class CouponWhiteController {

    @Autowired
    private CouponWhiteService couponWhiteService;

    @GetMapping("/listPage")
    public Result<IPage<CouponWhite>> listPage(CouponWhiteQueryReq req) {
        return couponWhiteService.listPage(req);
    }

    @GetMapping(value = "/{id}")
    public Result<CouponWhite> detail(@PathVariable Integer id) {
        return couponWhiteService.getById(id);
    }

    @PostMapping
    public Result add(@RequestBody CouponWhite couponWhite) {
        return couponWhiteService.add(couponWhite);
    }

    @PutMapping
    public Result update(@RequestBody CouponWhite couponWhite) {
        return couponWhiteService.updateById(couponWhite);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return couponWhiteService.deleteByIds(ids);
    }

}